package hotel.base.oversea.utils;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;

import java.math.BigDecimal;

/**
 * 字符串处理常用功能
 */
@SuppressWarnings({"rawtypes", "unchecked"})
@Slf4j
public class ChannelEnums {


    /**
     * 渠道推送下游订单状态（携程采购和美团采购两个渠道推送给下游统一订单状态）
     */
    @Getter
    @AllArgsConstructor
    public enum OrderState {
        //CREATE(10, "订单创建"),//hhb订单创建未提交
        BOOKING(20, "预定中"),//已提交预定中
        BOOKINGSUCCSS(21, "预订成功"),//预订成功(已确认)(美团异步通知预定成功)
        FAILED(22, "预定失败"),
        CANCELING(30, "取消中"),
        CANCELSUCCSS(31, "取消成功"),//上游可能同步返回时：三种情况：返回成功 或者 同步返回取消中等待异步通知取消成功 或 返回失败
        CANCELFAILED(32,"取消失败"),//上游响应取消失败
        IN(50, "用户已入住");
        private final int code;
        private final String msg;

        public static String getDesc(Integer code) {
            ChannelEnums.OrderState[] businessModeEnums = values();
            for (ChannelEnums.OrderState businessModeEnum : businessModeEnums) {
                if (BigDecimal.valueOf(businessModeEnum.code()).compareTo(new BigDecimal(code))==0) {
                    return businessModeEnum.msg();
                }
            }
            return null;
        }
        public Integer code(){
            return this.code;
        }

        public String msg(){
            return this.msg;
        }

    }

    /**
     *  订单号命名
     */
    @Getter
    @AllArgsConstructor
    public enum Head{
        ORDER_HEAD_FP("fp", "飞猪前端"),
        ORDER_HEAD_SW("sw", "携程前端");
        private final String code;
        private final String msg;

        /**
         * 根据code得到枚举的msg
         *
         * @param code
         * @return
         */
        public static Front getMsg(String code) {
            Front[] front = Front.values();
            for (int i = 0; i < front.length; i++) {
                if (front[i].getCode().equals(code)) {
                    return front[i];
                }
            }
            return null;
        }
    }

    /**
     *  申请订单平台
     */
    @Getter
    @AllArgsConstructor
    public enum Front{
        MERCHANT_FG_FRONT("APPLY_HHB_FP", "飞猪前端"),
        MERCHANT_SW_FROMT("APPLY_HHB_SW", "携程前端");
        private final String code;
        private final String msg;

        /**
         * 根据code得到枚举的msg
         *
         * @param code
         * @return
         */
        public static Front getMsg(String code) {
            Front[] front = Front.values();
            for (int i = 0; i < front.length; i++) {
                if (front[i].getCode().equals(code)) {
                    return front[i];
                }
            }
            return null;
        }
    }

    /**
     *  采购渠道CODE
     *  美团 Meituan
     *  携程 Switchs
     */
    @Getter
    @AllArgsConstructor
    public enum ChannelCode {
        MT(1, "Meituan"),
        SW(2, "Switchs");
        private final int code;
        private final String name;
    }

    public Integer orderSource(String merchantOrderId_index){

        if(merchantOrderId_index.substring(0,2).equals("FM")){

        }else{

        }


        return 1;
    }

}
